package daily.jun0611;

import javax.swing.*;
import java.awt.*;

public class BorderLayOutTest {
    public static void main(String[] args) {
        SwingUtilities.invokeLater(()->createAndShow());
    }

    private static void createAndShow() {
        //1.创建窗体对象JFrame
        JFrame jFrame = new JFrame("布局管理器");
        jFrame.setSize(600,450);
        //窗口显示在300，400的位置
        jFrame.setLocation(300,400);
        jFrame.setVisible(true);
        jFrame.setDefaultCloseOperation(jFrame.EXIT_ON_CLOSE);

        //2.设置当前窗体使用哪一种布局---边界布局(BorderLayOut)
        jFrame.setLayout(new BorderLayout());

        //3.创建5个组件(按钮组件)
        JButton button1 = new JButton("页头PAGE_START");
        JButton button2 = new JButton("页尾PAGE_END");
        JButton button3 = new JButton("行首LINE_START");
        JButton button4 = new JButton("行尾LINE_END");
        JButton button5 = new JButton("中部CENTER");
        //4.将组件添加到容器当中
        jFrame.add(button1,BorderLayout.PAGE_START);
        jFrame.add(button2,BorderLayout.PAGE_END);
        jFrame.add(button3,BorderLayout.LINE_START);
        jFrame.add(button4,BorderLayout.LINE_END);
        jFrame.add(button5,BorderLayout.CENTER);
    }
}
